<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>数据管理器</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<jsp:include page="/PLUGIN/dbconsole/commons/include_all.jsp"></jsp:include>
	</head>
	<body class="easyui-layout">
		<div
			data-options="region:'north',title:'SQL执行器',split:false,border:false"
			style="height: 150px;">
			<a id="btnRun" href="#" class="easyui-linkbutton"
				style="margin: 4px;" data-options="iconCls:'icon-control-play'">执行SQL</a>
			<a id="btnRe" href="#" class="easyui-linkbutton" style="margin: 4px;"
				data-options="iconCls:'icon-pen'">记录SQL到输出控制台</a>
			<a id="btnclear" href="#" class="easyui-linkbutton"
				style="margin: 4px;" data-options="iconCls:'icon-cancel'">清空SQL</a>
			<a id="btnclearCon" href="#" class="easyui-linkbutton"
				style="margin: 4px;" data-options="iconCls:'icon-cancel'">清空输出控制台</a>
			<hr style="margin: 0px; padding: 0px;" />
			<textarea id="sqlTextboxId"
				style="width: 100%; height: 60px; border: 0px;"></textarea>
		</div>
		<div data-options="region:'south',title:'输出控制台',split:true"
			style="height: 100px;">
			<div id="consoleMessageId" style="padding: 4px;"></div>
		</div>
		<div
			data-options="region:'east',iconCls:'icon-reload',title:'服务中间件',split:true"
			style="width: 200px;">
			<div id="fileConsoleBoxId" style="padding: 4px;"></div>
			<form id="downloadForm" action="admin/HhcommonDataFiledownload.do"
				method="post">
				<input id="downloadpath" type="hidden" name="path">
			</form>
		</div>
		<div data-options="region:'west',title:'数据库',split:true"
			style="width: 200px; padding: 4px;">
			<c:forEach items="${list}" var="node">
				<c:set var="columns" value=""></c:set>
				<p style="display: ">
					<c:forEach items="${node.propertyNames}" var="column">
						<c:if test="${columns!=''}">
							<c:set var="columns" value="${columns},${column}"></c:set>
						</c:if>
						<c:if test="${columns==''}">
							<c:set var="columns" value="${column}"></c:set>
						</c:if>
					</c:forEach>
				</p>
				<p class="tablenames" title="${columns}"
					style="font-size: 12px; color: green; cursor: pointer;">
					${node.tableName}
				</p>
			</c:forEach>
		</div>
		<div id="dataresultBoxId" data-options="region:'center',title:'数据'"
			style="padding: 5px; background: #eee;">
			
		</div>
	</body>
	<script type="text/javascript">
	$(function() {
		$('.tablenames').bind(
				'click',
				function() {
					$('#sqlTextboxId').val('');
					$('#sqlTextboxId').val(
							'select ' + $(this).attr('title') + ' from '
									+ $.trim($(this).text()) + ' limit 50');
				});
		$('#btnRun').bind('click', function() {
			runsql();
		});
		$('#btnclear').bind('click', function() {
			$('#sqlTextboxId').val('');
		});
		$('#btnclearCon').bind('click', function() {
			$('#consoleMessageId').text('');
		});
		$('#btnRe').bind(
				'click',
				function() {
					if ($('#sqlTextboxId').val()) {
						$('#consoleMessageId').prepend(
								"记录sql:&nbsp;&nbsp;<b>"
										+ $('#sqlTextboxId').val()
										+ "</b><br/><br/>");
					}
				});
		loadFiles();
	});
	function loadFiles(path) {
		if (!path) {
			path = null;
		}
		$('#fileConsoleBoxId').text("loading...");
		$('#fileConsoleBoxId').load('admin/HhcommonDataFileMng.do', {
			'path' : path
		});
	}
	function runsql() {
		if($('#sqlTextboxId').val()){
			if(!confirm("确定执行该语句么？（该操作将无法返回!）")){
				return false;
			}
			$('#dataresultBoxId').load('admin/HhcommonRunsql.do',{sql:$('#sqlTextboxId').val()},function(flag){
				$('#consoleMessageId').prepend($('#logsId').text()+"<br/><br/>");
			});
		}
	}
	//-->
</script>
</html>
